/**
 * package
 */
package com.android.todayview;

import java.util.Calendar;
import android.graphics.Color;

/**
 * This class is used to describe the Day Style, Main including is color
 **/
public class DayStyle {
	
	/** DayNames for one week */
	private static String[] getWeekDayNames() {
		String[] vec = new String[10];
		vec[Calendar.SUNDAY] = "Sun";
		vec[Calendar.SATURDAY] = "Sat";
		vec[Calendar.FRIDAY] = "Fri";
		vec[Calendar.THURSDAY] = "Thu";
		vec[Calendar.WEDNESDAY] = "Wed";
		vec[Calendar.TUESDAY] = "Tue";
		vec[Calendar.MONDAY] = "Mon";
		
		return vec;
	}

	/** vecStrWeekDayNames is an array for one week */
	private final static String[] vecStrWeekDayNames = getWeekDayNames();
	
	/** Get every day's name of week */
	public static String getWeekDayName(int iDay) {
		return vecStrWeekDayNames[iDay];
	}

	/** Define different colors */
	public final static int iColorFrameHeader = 0xff666666;
	public final static int iColorFrameHeaderHoliday = 0xff707070;
	public final static int iColorTextHeader = 0xffcccccc;
	
	public final static int iColorText = 0xffdddddd;
	public final static int iColorBkg = 0xff888888;
	public final static int iColorBkgHoliday = 0xffaaaaaa;

	public final static int iColorTextToday = 0xff002200;
	public final static int iColorBkgToday = 0xff88bb88;

	public final static int iColorTextSelected = 0xff001122;
	public final static int iColorBkgSelectedLight = 0xffbbddff;
	public final static int iColorBkgSelectedDark = 0xff225599;

	public final static int iColorTextFocused = 0xff221100;
	public final static int iColorBkgFocusLight = 0xffffddbb;
	public final static int iColorBkgFocusDark = 0xffaa5500;

	/** FrameHeader Color: holiday or not */
	public static int getColorFrameHeader(boolean bHoliday) {
		if (bHoliday) {
			return iColorFrameHeaderHoliday;
		}
		return iColorFrameHeader;
	}

	/** TextHeader Color: holiday weekday  */
	public static int getColorTextHeader(boolean bHoliday,int iWeekDay) {
		if (bHoliday) {
			if (iWeekDay == Calendar.SATURDAY) 
				return Color.BLUE;
			else
				return Color.RED;
		}
		return iColorTextHeader;
	}

	/** TextColor: Get different text color */
	public static int getColorText(boolean bHoliday, boolean bToday,int iDayOfWeek) {
		if (bToday)
			return iColorTextToday;
		if (bHoliday) {
			if (iDayOfWeek == Calendar.SATURDAY) {
				return Color.BLUE;
			}
			else
			    return Color.RED;
		}    
		return iColorText;
	}

	/** BackgroundColor: Holiday and Today and Normal will use different Bkg colors */
	public static int getColorBkg(boolean bHoliday, boolean bToday) {
		if (bToday)
			return iColorBkgToday;
		if (bHoliday) 
			return iColorBkgHoliday;
		return iColorBkg;
	}

	/** Get the first day in the calendar interface */
	public static int getWeekDay(int index, int iFirstDayOfWeek) {
		/**  */
		int iWeekDay = -1;
		/** If first day in the calendar is monday, weekday is index add monday,
		 *  if first day in the calendar is sunday, weekday is index add sunday */
		if (iFirstDayOfWeek == Calendar.MONDAY) {
			iWeekDay = index + Calendar.MONDAY;
			if (iWeekDay > Calendar.SATURDAY)
				iWeekDay = Calendar.SUNDAY;
		}
		if (iFirstDayOfWeek == Calendar.SUNDAY) {
			iWeekDay = index + Calendar.SUNDAY;
		}
		return iWeekDay;
	}

}

